VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ClsMoneda"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public WithEvents orset As ClsRecordset
Attribute orset.VB_VarHelpID = -1

Public Event DataChanged()

Public cod As String
Public nombre As String
Public nombre_moneda As String

' Class event handlers
Private Sub Class_Initialize()
    Set orset = New ClsRecordset
    orset.setCampos dbCampos(mon)
    orset.setTablas Array(mon)
End Sub
Private Sub Class_Terminate()
    Set orset = Nothing
End Sub
' Generic Data management methods
Public Sub consulta()
    orset.consulta
End Sub
Public Sub consultaDatos(codMoneda As String)
    orset.consulta Array(mon_id & "=" & codMoneda)
    orset.CierraRec
End Sub
Public Sub consultaDesde(codMoneda As String)
    orset.consulta Array(mon_id & ">" & codMoneda)
End Sub

Public Sub Nuevo(nom As String, NomMoneda As String)
    orset.sInsert Array("", nom, NomMoneda)
End Sub
Public Sub Modificar(codig As String, nom As String, NomMoneda As String)
    orset.sUpdate Array(codig, nom, NomMoneda)
End Sub
Public Sub Borrar(codig As String)
    orset.sDelete Array(mon_id & "=" & codig)
End Sub
Public Sub Reload_members(Optional orec As ClsRecordset)
    If Not orec Is Nothing Then
        Set orset = orec
    End If
    With orset
        cod = .getDato(mon_id)
        nombre = .getDato(mon_nombre)
        nombre_moneda = .getDato(mon_moneda)
    End With
    RaiseEvent DataChanged
End Sub
' Class methods
Public Sub llenaCombo(cajaCombo As ComboBox, conCodigo As Boolean, Optional conBs As Boolean = True)
    Dim i As Integer
    If Not conBs Then
        consultaDesde "1"
    Else
        consulta
    End If
    i = 0
    cajaCombo.Clear
    If conCodigo Then
        While orset.CanMoveNext
            cajaCombo.AddItem cod & " - " & nombre
            cajaCombo.ItemData(i) = cod
            orset.MoveNext
            i = i + 1
        Wend
    Else
        While orset.CanMoveNext
            cajaCombo.AddItem nombre
            cajaCombo.ItemData(i) = cod
            orset.MoveNext
            i = i + 1
        Wend
    End If
    If cajaCombo.ListCount > 1 Then
        'siempre selecciona la primera moneda (Bs)
        cajaCombo.ListIndex = 0
    End If
End Sub

Private Sub orset_DataChanged()
    Reload_members
End Sub
